package com.soilflow.web.controller.dahu;

import com.soilflow.common.annotation.Log;
import com.soilflow.common.core.controller.BaseController;
import com.soilflow.common.core.domain.AjaxResult;
import com.soilflow.common.core.page.TableDataInfo;
import com.soilflow.common.domain.DahuLastestNews;
import com.soilflow.common.domain.DahuStop;
import com.soilflow.common.enums.BusinessType;
import com.soilflow.common.utils.poi.ExcelUtil;
import com.soilflow.info.service.IDahuLastestNewsService;
import com.soilflow.info.service.IDahuStopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 【最新消息】Controller
 * 
 * @author figol
 * @date 2023-10-30
 */
@RestController
@RequestMapping("/dahu/lastest/news")
public class DahuLastestNewsController extends BaseController
{

    @Autowired
    private IDahuStopService dahuStopService;
    @Autowired
    private IDahuLastestNewsService dahuLastestNewsService;



    /**
     * 查询站点列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DahuLastestNews dahuLastestNews)
    {
        startPage();
        List<DahuLastestNews> list = dahuLastestNewsService.queryList(dahuLastestNews);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:stop:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DahuStop dahuStop)
    {
        List<DahuStop> list = dahuStopService.selectDahuStopList(dahuStop);
        ExcelUtil<DahuStop> util = new ExcelUtil<DahuStop>(DahuStop.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取站点详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:stop:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(dahuStopService.selectDahuStopById(id));
    }

    /**
     * 新增站点
     */
    @PreAuthorize("@ss.hasPermi('system:stop:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DahuStop dahuStop)
    {
        return toAjax(dahuStopService.insertDahuStop(dahuStop));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:stop:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DahuStop dahuStop)
    {
        return toAjax(dahuStopService.updateDahuStop(dahuStop));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:stop:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dahuStopService.deleteDahuStopByIds(ids));
    }
}
